import React, { Component } from "react";

export default class App extends Component {
  constructor(props) {
    super(props);
    this.fileRef = React.createRef();
  }
  state = {
    file: "",
  };
  huoqu = () => {
    console.log(this.fileRef.current);
  };
  render() {
    return (
      <div>
        <input type="file" ref={this.fileRef} name="" id="" />
        <button onClick={this.huoqu}>获取元素</button>
      </div>
    );
  }
}
